#!/usr/bin/env python
# -*- coding: utf-8 -*-
#

from hash_ring import HashRing

def hashtest(ring) :
    keys = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    hashed = {}
    for server in servers :
        hashed[ server ] = []
    for key in keys :
        server = ring.get_node(key)
        #print ' ',key,'goes to',server
        hashed[ server ].append( key )

    print '------------------------------------------------------------'
    for server in servers :
        print server,':',hashed[server]
    ## hashtest()


servers = ['127.0.0.1:1111',
           '127.0.0.1:2222',
           '127.0.0.1:3333',
           '127.0.0.1:4444',
           '127.0.0.1:5555']

ring = HashRing(servers)
hashtest(ring)

servers = ['127.0.0.1:1111',
           '127.0.0.1:2222',
           '127.0.0.1:3333',
           '127.0.0.1:4444',
           '127.0.0.1:5555',
           '127.0.0.1:6666',
           '127.0.0.1:7777']

ring = HashRing(servers)
hashtest(ring)

servers = ['127.0.0.1:1111',
           '127.0.0.1:6666',
           '127.0.0.1:7777',
           '127.0.0.1:4444',
           '127.0.0.1:5555']

ring = HashRing(servers)
hashtest(ring)

servers = ['127.0.0.1:1111',
           '127.0.0.1:2222',
           '127.0.0.1:3333',
           '127.0.0.1:4444',
           '127.0.0.1:5555',
           '127.0.0.1:6666',
           '127.0.0.1:7777',
           '127.0.0.1:8888',
           '127.0.0.1:9999']

ring = HashRing(servers)
hashtest(ring)


